(function(){
    publicParam.voteSize = 20;
    /**
    * 初始化
    */
	async function init(){
        if (!checkConnect()) return;
        var rtn = await loadManbers();
        if (rtn){
            if (!publicParam.voteList){
                setLoading(1);
                publicParam.voteNum = await numOfVote();
                setLoading(0);
            }
            if(!publicParam.votePage) publicParam.votePage = 0;
            //如果投票数多于每页显示的数量，则显示分页按钮
            if(publicParam.voteNum>publicParam.voteSize){
                var param = {
                    total:publicParam.voteNum,
                    size:publicParam.voteSize,
                    current:publicParam.votePage,
                    fn:load,
                };
                loadPage("/common/paging","paging",param);
            }
            load(publicParam.votePage);
            getNode("refresh").onclick = ()=>{
                //强制刷新
                publicParam.voteList = null;
                publicParam.votePage = 0;
                init();
            }
        }
    }
    /**
    * 为了分页每次载入一定量的薪酬
    */
	async function load(paging){
        setLoading(1);
        publicParam.proposalsPage = paging;
        publicParam.voteList = await getVoteFromTo();
        loadPage("/vote/listItem","list");
        setLoading(0);
    }
	init();
})();